/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author c0909h1169
 */
public class BusinessAlive implements Runnable{

    String name;
    Thread ObjectThread;

    public BusinessAlive() {
    }

    public BusinessAlive(String name){
        this.name = name;
        ObjectThread = new Thread(this,name);
        System.out.println("New task are starting: "+ObjectThread);
        ObjectThread.start();

    }


    public void run()
    {
        for(int i =0;i<=1;i++)
        {
            System.out.println(name+": "+i);
            try{
            Thread.sleep(3000);
            }
            catch(InterruptedException ex)
            {
            }
            
        }
        System.out.println(name+" finish and exiting");
        
       
    }
}
class Exec{
    public static void main(String Args[])
    {
        BusinessAlive obj1 = new BusinessAlive("Meeting Deadline");
        BusinessAlive obj2 = new BusinessAlive("Schedule Variance");
        BusinessAlive obj3 = new BusinessAlive("Efforts Customer");
        System.out.println("First Task is in process and alive: "+ obj1.ObjectThread.isAlive());
        System.out.println("Second Task is in process and alive: "+ obj2.ObjectThread.isAlive());
        System.out.println("Third Task is in process and alive: "+ obj3.ObjectThread.isAlive());
        try
        {
            obj1.ObjectThread.join();
            obj2.ObjectThread.join();
            obj3.ObjectThread.join();
            Thread.sleep(3000);
        }
        catch(InterruptedException ex)
        {
        }
        System.out.println("First Task is alive "+obj1.ObjectThread.isAlive());
        System.out.println("Second Task is alive "+obj2.ObjectThread.isAlive());
        System.out.println("Third Task is alive "+obj3.ObjectThread.isAlive());
        System.out.println("All task is over and exiting.");
    }
}


    
